1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgAttributeIterator; 26 27 private import glib.ListSG; 28 private import gobject.ObjectG; 29 private import pango.PgAttribute; 30 private import pango.PgFontDescription; 31 private import pango.PgLanguage; 32 private import pango.c.functions; 33 public import pango.c.types; 34 35 36 /** 37 * A `PangoAttrIterator` is used to iterate through a `PangoAttrList`. 38 * 39 * A new iterator is created with [method@Pango.AttrList.get_iterator]. 40 * Once the iterator is created, it can be advanced through the style 41 * changes in the text using [method@Pango.AttrIterator.next]. At each 42 * style change, the range of the current style segment and the attributes 43 * currently in effect can be queried. 44 */ 45 public class PgAttributeIterator 46 { 47 /** the main Gtk struct */ 48 protected PangoAttrIterator* pangoAttrIterator; 49 protected bool ownedRef; 50 51 /** Get the main Gtk struct */ 52 public PangoAttrIterator* getPgAttributeIteratorStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return pangoAttrIterator; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected void* getStruct() 61 { 62 return cast(void*)pangoAttrIterator; 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (PangoAttrIterator* pangoAttrIterator, bool ownedRef = false) 69 { 70 this.pangoAttrIterator = pangoAttrIterator; 71 this.ownedRef = ownedRef; 72 } 73 74 75 /** */ 76 public static GType getType() 77 { 78 return pango_attr_iterator_get_type(); 79 } 80 81 /** 82 * Copy a `PangoAttrIterator`. 83 * 84 * Returns: the newly allocated 85 * `PangoAttrIterator`, which should be freed with 86 * [method@Pango.AttrIterator.destroy] 87 */ 88 public PgAttributeIterator copy() 89 { 90 auto __p = pango_attr_iterator_copy(pangoAttrIterator); 91 92 if(__p is null) 93 { 94 return null; 95 } 96 97 return ObjectG.getDObject!(PgAttributeIterator)(cast(PangoAttrIterator*) __p, true); 98 } 99 100 /** 101 * Destroy a `PangoAttrIterator` and free all associated memory. 102 */ 103 public void destroy() 104 { 105 pango_attr_iterator_destroy(pangoAttrIterator); 106 } 107 108 /** 109 * Find the current attribute of a particular type 110 * at the iterator location. 111 * 112 * When multiple attributes of the same type overlap, 113 * the attribute whose range starts closest to the 114 * current location is used. 115 * 116 * Params: 117 * type = the type of attribute to find 118 * 119 * Returns: the current 120 * attribute of the given type, or %NULL if no attribute 121 * of that type applies to the current location. 122 */ 123 public PgAttribute get(PangoAttrType type) 124 { 125 auto __p = pango_attr_iterator_get(pangoAttrIterator, type); 126 127 if(__p is null) 128 { 129 return null; 130 } 131 132 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p); 133 } 134 135 /** 136 * Gets a list of all attributes at the current position of the 137 * iterator. 138 * 139 * Returns: a list of all attributes for the current range. To free 140 * this value, call [method@Pango.Attribute.destroy] on each 141 * value and g_slist_free() on the list. 142 * 143 * Since: 1.2 144 */ 145 public ListSG getAttrs() 146 { 147 auto __p = pango_attr_iterator_get_attrs(pangoAttrIterator); 148 149 if(__p is null) 150 { 151 return null; 152 } 153 154 return new ListSG(cast(GSList*) __p, true); 155 } 156 157 /** 158 * Get the font and other attributes at the current 159 * iterator position. 160 * 161 * Params: 162 * desc = a `PangoFontDescription` to fill in with the current 163 * values. The family name in this structure will be set using 164 * [method@Pango.FontDescription.set_family_static] using 165 * values from an attribute in the `PangoAttrList` associated 166 * with the iterator, so if you plan to keep it around, you 167 * must call: 168 * `pango_font_description_set_family (desc, pango_font_description_get_family (desc))`. 169 * language = location to store language tag 170 * for item, or %NULL if none is found. 171 * extraAttrs = location in which to store a list of non-font attributes 172 * at the the current position; only the highest priority 173 * value of each attribute will be added to this list. In 174 * order to free this value, you must call 175 * [method@Pango.Attribute.destroy] on each member. 176 */ 177 public void getFont(PgFontDescription desc, out PgLanguage language, out ListSG extraAttrs) 178 { 179 PangoLanguage* outlanguage = null; 180 GSList* outextraAttrs = null; 181 182 pango_attr_iterator_get_font(pangoAttrIterator, (desc is null) ? null : desc.getPgFontDescriptionStruct(), &outlanguage, &outextraAttrs); 183 184 language = ObjectG.getDObject!(PgLanguage)(outlanguage); 185 extraAttrs = new ListSG(outextraAttrs); 186 } 187 188 /** 189 * Advance the iterator until the next change of style. 190 * 191 * Returns: %FALSE if the iterator is at the end 192 * of the list, otherwise %TRUE 193 */ 194 public bool next() 195 { 196 return pango_attr_iterator_next(pangoAttrIterator) != 0; 197 } 198 199 /** 200 * Get the range of the current segment. 201 * 202 * Note that the stored return values are signed, not unsigned 203 * like the values in `PangoAttribute`. To deal with this API 204 * oversight, stored return values that wouldn't fit into 205 * a signed integer are clamped to %G_MAXINT. 206 * 207 * Params: 208 * start = location to store the start of the range 209 * end = location to store the end of the range 210 */ 211 public void range(out int start, out int end) 212 { 213 pango_attr_iterator_range(pangoAttrIterator, &start, &end); 214 } 215 }